package Utils;
import net.sf.jml.message.MsnInstantMessage;
/*
 * Wrote by GnuFabio
 */
public class HtmlParser {
    private String str2ret = "<html><body></body></html>";

    private String getBOpenTag(MsnInstantMessage m){
        if (m.isBold())
            return "<b>";
        else
            return "";
    }
    private String getBCloseTag(MsnInstantMessage m){
        if (m.isBold())
            return "</b>";
        else
            return "";
    }
    private String getIOpenTag(MsnInstantMessage m){
        if (m.isItalic())
            return "<i>";
        else
            return "";
    }
    private String getICloseTag(MsnInstantMessage m){
        if (m.isItalic())
            return "</i>";
        else
            return "";
    }
    private String getUOpenTag(MsnInstantMessage m){
        if (m.isUnderline())
            return "<u>";
        else
            return "";
    }
    private String getUCloseTag(MsnInstantMessage m){
        if (m.isUnderline())
            return "</u>";
        else
            return "";
    }

    public String getParsedMessage(MsnInstantMessage message){
        return str2ret.replace("</body></html>", message.getDisplayName() + " scrive:<br>" + getBOpenTag(message)
                + getIOpenTag(message) + getUOpenTag(message) + message.getContent() + getBCloseTag(message)
                + getICloseTag(message) + getUCloseTag(message) + "<br></body></html>");
    }
}
